package cn.weekimwee.firstlineofcodeforkotlin

import android.app.Activity

/**
 * Created by Wee Kim Wee on 2018/2/8.
 */
object ActivityCollector{
    private val activities= mutableListOf<Activity>()

    fun addActivity(activity: Activity){
        activities.add(activity)
    }

    fun removeActivity(activity: Activity){
        activities.remove(activity)
    }

    fun finishAll(){
        activities.forEach {
            if(!it.isFinishing) it.finish()
        }
    }
}